package com.liu.design.building.singleton;

/**
 * @author LIU
 * @version 1.0
 * @date 2023/8/7 10:39
 * @description 单例模式，懒汉模式
 *
 * 静态内部类：静态内部类会在使用的时候才加载
 *
 * 优点：写法优雅，利用了java语法特点
 */
public class LazyStaticInnerClassSingleton {

    private LazyStaticInnerClassSingleton() {
    }

    public static  LazyStaticInnerClassSingleton getInstance() {
        return LazyHolder.INSTANCE;
    }

    private static class LazyHolder{
        private static final LazyStaticInnerClassSingleton INSTANCE = new LazyStaticInnerClassSingleton();
    }
}
